<!DOCTYPE html>
<html lang="zh-CN">
   {include file='index/header' /}
<body class="sticky-header">

<section>
    <!-- left side start-->
     {include file='index/menu' /}
    <!-- left side end-->
    
    <!-- main content start-->
    <div class="main-content" >

        <!-- header section start-->
        {include file='index/header_section' /}
        <!-- header section end-->

        <!--body wrapper start-->
         <section class="panel">
                    <header class="panel-heading">
                        修改商品
                    </header>
                    <div class="panel-body" >
                        <form role="form" action="saveProduct" class="form-horizontal" method="post" enctype="multipart/form-data" >
                            <input type="hidden" name="id" value="{$data.id}" />
                            
                            <div class="form-group">
                                <div class="col-md-3">
                                 <label for="price">价格</label>
                                 <input type="text" class="form-control"  name="price" value="{$data.price}">
                                </div>

                            </div>
                            
                            <div class="form-group">
                                <div class="col-md-3">
                                    <label for="name">名称</label>
                                    <input type="text" class="form-control" name="name" value="{$data.name}">
                                </div>
                            </div>              
             
                            
                            <div class="form-group">
                                <div class="col-md-12">
                                     <label for="content">描述</label>
                                    <textarea class="form-control" rows="3" id="content" name="detail">{$data.detail}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                 <div class="col-md-12">
                                    <label for="mainpic">首页图片<small class="text-danger">(推荐图片尺寸180px*180px)</small></label>
                                    <a href="javascript:void(0);"class="avatar_uplpad_btn" id="avatar_uplpad_btn">选择图片</a> 
                                    <div id="main_pic"> 
                                       {neq name="data.mainPicture" value=""}
                                            <div style= 'margin:0px 5px 0px 5px;width:105px;heith:105px;float:left;border-color:#0000FF;border: 2px solid ;' onclick = 'javascript:shanchu($(this))'>
                                                <img style='width:100px;heith:100px;' src='{$data.mainPicture}'/>
                                                <input type='hidden' name='mainPic' value='{$data.mainPicture}' />
                                            </div>
                                       {/neq}
                                    </div> 
                                    
                                 </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="contentpic">详情图片<small class="text-danger">(第一张详情图为主图,从第二张开始,后面的图片请按照颜色顺序添加)</small></label>
                                    <a href="javascript:void(0);"class="avatar_uplpad_btn" id="avatar_uplpad_btn2">添加图片</a> 
                                    <div id="detail_pic"> 
                                        {volist name="Pics" id="vo"}
                                           <div style= 'margin:0px 5px 0px 5px;width:105px;heith:105px;float:left;border-color:#0000FF;border: 2px solid ;' onclick = 'javascript:shanchu($(this))'>
                                               <img src='{$vo.url}' style='width:100px;heith:100px;float:left;' />
                                               <input type='hidden' name='detailPic[]' value='{$vo.url}' />
                                           </div>

                                        {/volist}
                                    </div> 
                                    
                                 </div>
                            </div>
                            
                            
                            <div class="form-group">
                                <div class="col-md-12">
                                    <button type="submit" class="btn btn-primary" id="send">完成</button>
                                </div>
                             </div>
                               
                            
                           <div id="delPic" style="display: none">
                               
                           </div>
                            
                        </form>

                    </div>
                </section>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by ThemeBucket
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<script src="{:PUBLICS}js/plupload/plupload.full.min.js"></script>
<script src="{:PUBLICS}js/jquery-1.10.2.min.js"></script>
<script src="{:PUBLICS}js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="{:PUBLICS}js/jquery-migrate-1.2.1.min.js"></script>
<script src="{:PUBLICS}js/bootstrap.min.js"></script>
<script src="{:PUBLICS}js/modernizr.min.js"></script>
<script src="{:PUBLICS}js/jquery.nicescroll.js"></script>

<script type="text/javascript" src="{:PUBLICS}js/ckeditor/ckeditor.js"></script>

<script type="text/javascript" src="{:PUBLICS}js/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script>
<script type="text/javascript" src="{:PUBLICS}js/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>

<!--common scripts for all pages-->
<script src="{:PUBLICS}js/scripts.js"></script>
<script>
    function shanchu(that){
         if(confirm("是否删除")){
            that.remove();
            
            var url = "delPhoto.html";
            var Timg = that.find('img').attr('src');
            
            $('#delPic').append("<input type='hidden' name='delPic[]' value='"+Timg+"'>");
            
        }
        
    }
    
    
    var uploader_avatar = new plupload.Uploader({
    //创建实例的构造方法 
    runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序 
    browse_button: ['avatar_uplpad_btn'], // 上传按钮 
    url: "savePic", //远程上传地址 
    flash_swf_url: 'js/plugins/plupload/Moxie.swf', //flash文件地址 
    silverlight_xap_url: 'js/plugins/plupload/Moxie.xap', //silverlight文件地址 
    filters: { 
        max_file_size: '10mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb） 
        mime_types: [//允许文件上传类型 
            {title: "files", extensions: "jpg,png,gif,jpeg"} 
        ] 
    }, 
    multi_selection: false, //true:ctrl多文件上传, false 单文件上传 
    init: { 
        FilesAdded: function(up, files) { //文件上传前 
 
            uploader_avatar.start(); 
        }, 
        UploadProgress: function(up, file) { //上传中，显示进度条 
            var percent = file.percent; 
            $("#" + file.id).find('.bar').css({"width": percent + "%"}); 
            $("#" + file.id).find(".percent").text(percent + "%"); 
        }, 
        FileUploaded: function(up, file, info) { //文件上传成功的时候触发 
            var data = eval("(" + info.response + ")");//解析返回的json数据 
            console.log(data);
            $("#main_pic").html("<div style= 'margin:0px 5px 0px 5px;width:105px;heith:105px;float:left;border-color:#0000FF;border: 2px solid ;' onclick = 'javascript:shanchu($(this))'><img style='width:100px;heith:100px;' src='" + data.pic + "'/><input type='hidden' name='mainPic' value='"+ data.pic +"' /></div>") ;
        }, 
        Error: function(up, err) { //上传出错的时候触发 
            alert(err.message); 
        } 
    } 
    }); 
    uploader_avatar.init();
    
    var uploader_avatar2 = new plupload.Uploader({
    //创建实例的构造方法 
    runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序 
    browse_button: ['avatar_uplpad_btn2'], // 上传按钮 
    url: "savePic", //远程上传地址 
    flash_swf_url: 'js/plugins/plupload/Moxie.swf', //flash文件地址 
    silverlight_xap_url: 'js/plugins/plupload/Moxie.xap', //silverlight文件地址 
    filters: { 
        max_file_size: '10mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb） 
        mime_types: [//允许文件上传类型 
            {title: "files", extensions: "jpg,png,gif,jpeg"} 
        ] 
    }, 
    multi_selection: false, //true:ctrl多文件上传, false 单文件上传 
    init: { 
        FilesAdded: function(up, files) { //文件上传前 
 
            uploader_avatar2.start(); 
        }, 
        UploadProgress: function(up, file) { //上传中，显示进度条 
            var percent = file.percent; 
            $("#" + file.id).find('.bar').css({"width": percent + "%"}); 
            $("#" + file.id).find(".percent").text(percent + "%"); 
        }, 
        FileUploaded: function(up, file, info) { //文件上传成功的时候触发 
            var data = eval("(" + info.response + ")");//解析返回的json数据 
            $("#detail_pic").append("<div style= 'margin:0px 5px 0px 5px;width:105px;heith:105px;float:left;border-color:#0000FF;border: 2px solid ;' onclick = 'javascript:shanchu($(this))'><img src='" + data.pic + "' style='width:100px;heith:100px;float:left;' /><input type='hidden' name='detailPic[]' value='"+ data.pic +"' /></div>") ;
        }, 
        Error: function(up, err) { //上传出错的时候触发 
            alert(err.message); 
        } 
    } 
    }); 
    uploader_avatar2.init();
</script>


</body>
</html>
